package com.nl.lib_project.view.androidpicker

import android.app.Activity
import com.github.gzuliyujiang.wheelpicker.widget.NumberWheelLayout
import com.github.gzuliyujiang.wheelview.contract.TextProvider

/** 作者: wangfei 创建时间: 2022/5/11 包名: com.nl.lib_project.view.androidpicker 类名: NumberWheelLayout */
open class CurNumberWheelLayout(activity: Activity, var textProviderValue: String) :
    NumberWheelLayout(activity) {

  override fun setRange(min: Float, max: Float, step: Float) {
    val minValue = min.coerceAtMost(max)
    val maxValue = min.coerceAtLeast(max)
    // 指定初始容量，避免OutOfMemory
    val data: ArrayList<TextProvider> = ArrayList()
    var i = minValue
    while (i <= maxValue) {
      data.add(CurPickerTextProvider((i + step).toString() + textProviderValue))
    }
    wheelView.data = data
  }
}
